<?php
/**
 * file:core.php
 * This file is part of J-Game.
 *
 * @link    https://www.f4soft.com
 * @document https://www.f4soft.com
 * @contact 173120209@qq.com
 * @autho   :jackliang
 */

require_once("lib/function.php");

function loadByNamespace($classname) {
    $class_path = str_replace('\\', DIRECTORY_SEPARATOR, $classname);
    if (strpos($classname, 'F4soft\\') === 0) {
        $class_file = __DIR__ . substr($class_path, strlen('F4soft'))
            . '.php';
    } else {
        $class_file = __DIR__ . DIRECTORY_SEPARATOR . '..'
            . DIRECTORY_SEPARATOR . "$class_path.php";
    }
    if (is_file($class_file)) {
        require_once($class_file);
        if (class_exists($classname, false)) {
            return true;
        }
    }
    return false;
}

spl_autoload_register('loadByNamespace');